#lang racket
;;;使用牛顿迭代法

(define sqrt
  (lambda (x)
    (define square
      (lambda (x)
      (* x x)))
    (define good-enough?
      (lambda (guess)
        (< (abs (- (square guess) x)) 0.001)))
     (define average
       (lambda (x y)
         (/ (+ x y) 2)))
     (define improve 
       (lambda (guess)
         (average guess (/ x guess))))
     (define sqrt-iter
       (lambda (guess)
         (if (good-enough? guess)
             guess
             (sqrt-iter (improve guess)))))
     (sqrt-iter 1.0)))
